﻿var UTIL = {};
UTIL.string = {};

UTIL.string.toHHMMSS = function (milliseconds) {
    var secs = milliseconds / 1000;
    var hours = Math.floor(secs / 3600);
    var minutes = Math.floor((secs - (hours * 3600)) / 60);
    var seconds = Math.floor(secs - (hours * 3600) - (minutes * 60));

    if (hours < 10) { hours = "0" + hours; }
    if (minutes < 10) { minutes = "0" + minutes; }
    if (seconds < 10) { seconds = "0" + seconds; }
    return hours + ':' + minutes + ':' + seconds;
}

UTIL.string.toHMM = function (milliseconds) {
    var secs = milliseconds / 1000;
    var hours = Math.floor(secs / 3600);
    var minutes = Math.floor((secs - (hours * 3600)) / 60);

    if (minutes < 10) { minutes = "0" + minutes; }
    return hours + ':' + minutes;
}